package com.smrtcold.dev.dto.dev.base;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * Copyright (C) SmartCold 版权所有
 *
 * @author MaQiang34
 * @Description: 盒子标准数据
 * @createDate:2018-12-11 10:38
 * @version:V1.0
 */
@Getter
@Setter
public class Point implements Cloneable, Serializable {
    private String devid;
    private String addres;
    private String name;//
    private Number value;
    private Double hex;//倍率
    private Double radix;//进制  除  /60
    private Long t;
    private Integer status;
    private Date timestamp;
    private Integer oper=0;//拓展操作  0:red 1:set
    private Integer hour,minute;
    private Double[] defvalue;



    public Point() {
    }

    public Point(String name,String addres){
        this.name = name;
        this.addres = addres;
    }

    public Point(String name, Double value) {
        this.name = name;
        this.value = value;
    }

    public Point(Double value, Date timestamp) {
        this.value = value;
        this.timestamp = timestamp;
    }

    public Point(String name, Double value, Long t) {
        this.name = name;
        this.value = value;
        this.t = t;
    }

    /**
     * 1000
     * @param value
     * @param time
     * @return
     */
    public boolean isChange(Number value,Long time) {
        if(null == this.value || !this.value.equals(value)||(time-this.t)>1800000){
            this.value = value.doubleValue();
            this.t = time;
            return true;
        }else{
            return false;
        }
    }

    @Override
    public Point clone() {
        try {
            return (Point) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return this.clone();
    }
}
